package mess;

public class LeeCode_1653 {
    public static void main(String[] args) {
        System.out.println(minimumDeletions("aababbab"));
        System.out.println(minimumDeletions("bbaaaaabb"));
    }
    private static int minimumDeletions(String s) {
        int start = 0;
        int end = s.length() - 1;
        int count = 0;
        while(start < end){
            while(start < end && s.charAt(start) == 'a'){
                start++;
            }
            start++;
            if(start < end)
                count++;
            while(start < end && s.charAt(end) == 'b'){
                end--;
            }
            end--;
            if(start < end)
                count++;
        }
        System.out.println(start + " " + end);
        return count;
    }
}
